#ifndef JOB_H
#define JOB_H

#include "BaseEntity.h"
#include <QJsonArray>
#include <QString>
#include <QStringList>

class Job : public BaseEntity{
public:
    qlonglong jobId;
    QString jobName;
    QString jobGroup;
    QString invokeTarget;
    QString cronExpression;
    QString misfirePolicy;
    QString concurrent;
    QString status;
    QString nextValidTime;

    QJsonObject toJson() const {
        QJsonObject obj;
        obj["jobId"] = QString::number(jobId);
        obj["jobName"] = jobName;
        obj["jobGroup"] = jobGroup;
        obj["invokeTarget"] = invokeTarget;
        obj["cronExpression"] = cronExpression;
        obj["misfirePolicy"] = misfirePolicy;
        obj["concurrent"] = concurrent;
        obj["status"] = status;
        obj["searchValue"] = searchValue;
        obj["createBy"] = createBy;
        obj["createTime"] = createTime;
        obj["updateBy"] = updateBy;
        obj["updateTime"] = updateTime;
        obj["remark"] = remark;
        obj["nextValidTime"] = nextValidTime;
        return obj;
    }

    static Job toJob(const QJsonObject &obj) {
        Job job;
        job.jobId = obj["jobId"].toVariant().toLongLong();
        job.jobName = obj["jobName"].toString();
        job.jobGroup = obj["jobGroup"].toString();
        job.invokeTarget = obj["invokeTarget"].toString();
        job.cronExpression = obj["cronExpression"].toString();
        job.misfirePolicy = obj["misfirePolicy"].toString();
        job.concurrent = obj["concurrent"].toString();
        job.status = obj["status"].toString();
        job.searchValue = obj["searchValue"].toString();
        job.createBy = obj["createBy"].toString();
        job.createTime = obj["createTime"].toString();
        job.updateBy = obj["updateBy"].toString();
        job.updateTime = obj["updateTime"].toString();
        job.remark = obj["remark"].toString();
        job.nextValidTime = obj["nextValidTime"].toString();
        return job;
    }
};
#endif // JOB_H
